package com.mingqijia.gassafety.db.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mingqijia.gassafety.db.entity.ConsumerLocation;
import com.mingqijia.gassafety.db.entity.FuncArea;
import com.mingqijia.gassafety.db.entity.vo.ConsumerLocationGroupItemVO;
import com.mingqijia.gassafety.db.entity.vo.ConsumerLocationItemVO;
import com.mingqijia.gassafety.db.entity.vo.ConsumerLocationStatItemVO;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: duanhongxiang
 * @Date: 2024/4/19 13:30
 */
@Mapper
@Repository
public interface ConsumerLocationMapper extends BaseMapper<ConsumerLocation> {

    /**
     * 地图客户数据按层级统计
     * @param spIds
     * @param level
     * @return
     */
    List<ConsumerLocationGroupItemVO> selectConsumerGroupList(@Param("spIds") List<String> spIds,
                                                              @Param("level") String level,
                                                              @Param("deviceStatus") String deviceStatus,
                                                              @Param("funcCodes") List<String> funcCodes);

    /**
     * 获取boundary里面客户数据
     * @param spIds
     * @param polygon
     * @return
     */
    List<ConsumerLocationItemVO> selectConsumerLocationList(@Param("spIds") List<String> spIds,
                                                            @Param("polygon") String polygon,
                                                            @Param("deviceStatus") String deviceStatus,
                                                            @Param("funcCodes") List<String> funcCodes );

    /**
     * 获取客户设备状态统计数据（单个）
     * @param spId
     * @param consumerId
     * @return
     */
    ConsumerLocationStatItemVO selectConsumerLocationStat(@Param("spId") String spId,
                                                          @Param("consumerId") Integer consumerId);

    /**
     * 更新客户设备数量
     * @param deviceInfo
     */
    void updateConsumerDeviceNum(@Param("spId") String spId,
                                 @Param("consumerId") Integer consumerId,
                                 @Param("deviceInfo") ConsumerLocationStatItemVO deviceInfo);

    /**
     * 更新客户地理位置
     * @param subsCode
     */
    void updateConsumerLocationBySubsCode(@Param("subsCode") String subsCode);


    /**
     * 获取boundary里面客户数据
     * @param spIds spIds
     * @param deviceStatus 设备状态
     * @param funcCodes 功能区权限控制
     * @param servicePkgMode
     * @return
     */
    ConsumerLocationItemVO selectAlertPosition(@Param("spIds") List<String> spIds,
                                               @Param("deviceStatus") String deviceStatus,
                                               @Param("funcCodes") List<String> funcCodes,
                                               @Param("servicePkgMode") String servicePkgMode);

    /**
     * 获取企业下地理位置的城市codes列表
     * @param spIds
     * @return
     */
    List<String> selectConsumerLocationCityCodes(@Param("spIds") List<String> spIds);


    /**
     * @Method getConsumerCountByFuncCode
     * @Author zm
     * @Description 获取区域下客户数量
     * @Date 2024/7/11 9:49
    */
    Integer getRelationCustomerNum(@Param("model") FuncArea model);


    List<Integer> getCustomerLocationIdsByFuncCode(@Param("model") FuncArea model);
}
